<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button class="btn">用户登录</button>
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>

    <script>
        document.querySelector('.btn')
        .addEventListener('click',
            () =>{
                // 用户登录
                axios({
                    url:'http://hmajax.itheima.net/api/login',
                    method:'post',
                    data:{
                        username:'itheima007',
                        password:'7654321'
                    }

                }).then(
                    res =>{
                        console.log(res);
                        
                    }
                )
            }
        )

    </script>
</body>
</html>